home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Developer Helper 1: Phil & Dave's Excellent CD
/
Excellent CD HFS.raw
/
Utilities
/
ResEdit
/
Examples
/
PExamples
/
Source
/
ICONLDEF.p
< prev
next >
Wrap
Text File
|
2022-08-05
|
2KB
|
84 lines
{
COPYRIGHT (C) 1984-1989 Apple Computer,Inc.
All rights reserved
}
UNIT IconLDEF;
INTERFACE
Uses MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
ResEd;
PROCEDURE DrawCell( Message: INTEGER; lSelect: BOOLEAN; lRect: Rect; lCell: Point;
lDataOffset, lDataLen: INTEGER; lh: ListHandle );
IMPLEMENTATION
{ This is the custom drawProc for the list (which contains the resource ID's). It
simply draws the icon in the given rect and frames a selection rect around it if
told to. }
PROCEDURE DrawCell(Message: INTEGER; lSelect: BOOLEAN; lRect: Rect; lCell: Point;
lDataOffset, lDataLen: INTEGER; lh: ListHandle);
VAR
i: Handle;
{ This routine simply looks up in the list at the given cell, extracts the ID and
gets the resource called for. Returns NIL if not found. Note, this assumes
the resfile is set up correctly }
FUNCTION IconFetch(lCell: point; lHandle: ListHandle): Handle ;
CONST IconSize = 128;
VAR
offset, len, id: INTEGER;
tempH:Handle;
BEGIN
IconFetch := NIL;
len:=2;
LGetCell(@id, len, lCell, lHandle); { Get the ID from the list. }
IF len > 0 THEN
BEGIN { Load the resource since we want to draw it. }
tempH:=Get1Res('ICON', id );
IF (SizeResource(tempH) < IconSize) THEN
IconFetch := NIL { Bad resource. }
ELSE
IconFetch := tempH;
END;
END;
BEGIN { DrawCell }
CASE message OF
lInitMsg:
BEGIN
WITH lh^^.indent DO
BEGIN
h := 8;
v := 8;
END;
END;
lDrawMsg, lHiliteMsg:
BEGIN
{ Always use the right sized rectangle. }
lRect.bottom := lRect.top + lh^^.cellSize.v;
lRect.right := lRect.left + lh^^.cellSize.h;
i := IconFetch(lCell, lh);
EraseRect(lRect);
InsetRect(lRect, lh^^.indent.h, lh^^.indent.v);
IF lSelect THEN
FrameRect(lRect); { Select the icon by framing it. }
IF i <> NIL THEN
BEGIN
IF i^ <> NIL THEN
BEGIN
InsetRect(lRect, lh^^.indent.h, lh^^.indent.v);
PlotIcon(lRect, i);
END;
END;
END;
END;
END;
END.